package com.by.controller;

import com.by.entity.ErpProductInquirySheet;
import com.by.service.ErpProductInquirySheetService;
import com.github.pagehelper.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;

/**
 * @author: Fsw
 * @com.by.controller
 * @date 2025-02-26 20:19
 */
public class ErpProductInquirySheetController {
    @Autowired
    private ErpProductInquirySheetService erpProductInquirySheetService;

    /**
     * 通过ID查询单条数据
     *
     * @param sn 主键
     * @return 实例对象
     */
    @ApiOperation("通过ID查询单条数据")
    @GetMapping("{sn}")
    public ResponseEntity<ErpProductInquirySheet> queryById(String sn) {
        return ResponseEntity.ok(erpProductInquirySheetService.queryById(sn));
    }

    /**
     * 分页查询
     *
     * @param erpProductInquirySheet 筛选条件
     * @param pageRequest            分页对象
     * @return 查询结果
     */
    @ApiOperation("分页查询")
    @GetMapping
    public ResponseEntity<Page<ErpProductInquirySheet>> paginQuery(ErpProductInquirySheet erpProductInquirySheet, PageRequest pageRequest) {
        return ResponseEntity.ok(erpProductInquirySheetService.paginQuery(erpProductInquirySheet, pageRequest));
    }

    /**
     * 新增数据
     *
     * @param erpProductInquirySheet 实例对象
     * @return 实例对象
     */
    @ApiOperation("新增数据")
    @PostMapping
    public ResponseEntity<ErpProductInquirySheet> add(ErpProductInquirySheet erpProductInquirySheet) {
        return ResponseEntity.ok(erpProductInquirySheetService.insert(erpProductInquirySheet));
    }

    /**
     * 更新数据
     *
     * @param erpProductInquirySheet 实例对象
     * @return 实例对象
     */
    @ApiOperation("更新数据")
    @PutMapping
    public ResponseEntity<ErpProductInquirySheet> edit(ErpProductInquirySheet erpProductInquirySheet) {
        return ResponseEntity.ok(erpProductInquirySheetService.update(erpProductInquirySheet));
    }

    /**
     * 通过主键删除数据
     *
     * @param sn 主键
     * @return 是否成功
     */
    @ApiOperation("通过主键删除数据")
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(String sn) {
        return ResponseEntity.ok(erpProductInquirySheetService.deleteById(sn));
    }
}
